package com.vo;

import com.bean.Commodity;

import java.io.Serializable;

public class CommodityVo implements Serializable {
    private String id;
    private String stock;
    private String cdyName;
    private String price;
    private String state;
    private String spare;

    public Commodity parse(){
        Commodity c = new Commodity();
        try {
            c.setId(Integer.valueOf(this.id));
        } catch (NumberFormatException e) {
        }
        try {
            c.setStock(Integer.valueOf(this.stock));
        } catch (NumberFormatException e) {
        }
        try {
            c.setPrice(Double.parseDouble(this.price));
        } catch (NumberFormatException e) {
        }
        try {
            c.setState(Integer.valueOf(this.state));
        } catch (NumberFormatException e) {
        }
        try {
            c.setSpare(Integer.valueOf(this.spare));
        } catch (NumberFormatException e) {
        }

        c.setCdyName(this.cdyName);


        return c;
    }

    @Override
    public String toString() {
        return "CommodityVo{" +
                "id='" + id + '\'' +
                ", stock='" + stock + '\'' +
                ", cdyName='" + cdyName + '\'' +
                ", price='" + price + '\'' +
                ", state='" + state + '\'' +
                ", spare='" + spare + '\'' +
                '}';
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getStock() {
        return stock;
    }

    public void setStock(String stock) {
        this.stock = stock;
    }

    public String getCdyName() {
        return cdyName;
    }

    public void setCdyName(String cdyName) {
        this.cdyName = cdyName;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getSpare() {
        return spare;
    }

    public void setSpare(String spare) {
        this.spare = spare;
    }
}
